
<div class="col-sm-7">
<form class="form-horizontal" id="task_runner" target="_self" method="post" action="/<%=@project_name%>/interactive/single">
  <div class="form-group">
    <!-- <select name="task" id="task_name"> -->
    <label for="task_name" class="col-xs-4 control-label">Task</label>
    <div class="col-xs-8">
    <select class="form-control input-sm" name="task" id="task_name">

      <!-- iterate through the tasks an create each one, checking to see if it matches our entity -->
      <% @task_classes.sort_by { |obj| obj.metadata[:pretty_name] }.each do |task_class|

            # Skip to the next task unless the current type is allowed
            next unless ( @entity.allowed_tasks.include?(task_class) ||
                          task_class.metadata[:allowed_types].include?("*") ) if @entity
        %>

        <!-- set up the task in an option box, default to create_entity -->
        <option value="<%= task_class.metadata[:name] %>"
          <% if @task_result %>
            <%= "selected='selected'" if @task_result.task_name == task_class.metadata[:name] %>
          <% else %>
            <%= "selected='selected'" if task_class.metadata[:name] == "create_entity" %>
          <% end %>
          ><%= task_class.metadata[:pretty_name] %>
        </option>

      <% end %>
    </select>
    </div>
  </div>
  <!-- Get all attributes and use this to create an entity -->
  <% if @entity %>
      <%= @entity.form  %>
      <input type="hidden" name="entity_id" value="<%=@entity.id%>">
  <% else %>
    <div class="form-group">
      <label for="entity_type" class="col-xs-4 control-label">Entity Type</label>
      <div class="col-xs-8">
        <select class="form-control input-sm" id="entity_type" name="entity_type"></select>
      </div>
    </div>
    <div class="form-group">
      <label for="attrib_name" class="col-xs-4 control-label">Entity Name</label>
      <div class="col-xs-8">
        <input type="text" class="form-control input-sm" id="attrib_name" name="attrib_name">
      </div>
    </div>
  <% end %>

  <div id="options"></div>

  <div id="strategy">
    <div class="form-group">
      <label for="attrib_name" class="col-xs-4 control-label">Iteration Strategy</label>
      <div class="col-xs-8">
        <select class="form-control input-sm" name="strategy" id="strategy">
          <!-- iterate through stategies -->
          <% Intrigue::StrategyFactory.list.each do |strategy_class| %>
           <% next unless strategy_class.metadata[:user_selectable] %>
            <option value="<%= strategy_class.metadata[:name] %>"
              <%= "selected='selected'" if strategy_class.metadata[:name] == "org_asset_discovery_active" %> >
              <%= strategy_class.metadata[:pretty_name] %>
            </option>
          <% end %>
        </select>
        <div class="hint">'Strategy' specifies the strategy that will be used to iterate.</div>
      </div>
    </div>
  </div>

  <div id="scan">
    <div class="form-group">
      <label for="attrib_name" class="col-xs-4 control-label">Iterations</label>
      <div class="col-xs-8">
        <select class="form-control input-sm" name="depth" id="depth">
          <option value=1 selected="true">Interactive</option>
          <option value=2>2 Iterations</option>
          <option value=3>3 Iterations</option>
          <option value=4>4 Iterations</option>
          <option value=5>5 Iterations</option>
          <option value=6>6 Iterations</option>
          <option value=7>7 Iterations</option>
          <option value=8>8 Iterations</option>
        </select>
        <div class="hint">'Iterations' specifies the depth to which the chosen strategy is run.</div>
      </div>
    </div>
  </div>

<!--
  <div id="handler">
    <div class="form-group">
      <label for="handler" class="col-xs-4 control-label">Handlers</label>
      <div class="col-xs-6">
        <select class="form-control input-sm" name="handler" id="handler">
          <option value="none" selected="true">None</option>
          <option value="s3_json">S3 JSON</option>
        </select>
      </div>
    </div>
  </div>
-->
  <div id="options">
    <div class="form-group">
      <label for="options" class="col-xs-4 control-label">&nbsp;</label>
      <div class="col-xs-6">
        <input id="auto_enrich" name="auto_enrich" type="checkbox" checked> Auto Enrich <br/>
      </div>
    </div>
  </div>
  <hr></hr>
  <input class="btn btn-primary" type="submit" value="Run Task">
</form>
</div>
<div class="col-sm-5">
<p>
<div id="description" name="description">[description]</div>
</p>
<p>
<div id="links" name="links">[links]</div>
</p>
</div>
<script type="text/javascript" src="/js/task.js"></script>
